package es.cazadoresmadridejos.web.util;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import es.cazadoresmadridejos.model.BaseEntity;

public class ListUtil {

	
	public static String toString(List<? extends Enum> list){
		String result = "";
		
		for (Enum enum1 : list) {
			if(StringUtils.isEmpty(result)){
				result = enum1.name();
			}else{
				result += "," + enum1.name();
			}
		}
		
		return result;
	}
	public static String toString(Enum[] list){
		String result = "";
		
		for (Enum enum1 : list) {
			if(StringUtils.isEmpty(result)){
				result = enum1.name();
			}else{
				result += "," + enum1.name();
			}
		}
		
		return result;
	}
	
	public static List<Long> toList(List<? extends BaseEntity> entities){
		List<Long> result = new ArrayList<Long>();
		
		for (BaseEntity entity : entities) {
			result.add(entity.getId());
		}
		
		return result;
		
	}
}
